from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from time import sleep
url=r"http://www.baidu.com"

# 指定chrome浏览器位置，options参数
chrome_location=r"D:\py\chrome\chrome-win\chrome.exe"
options=webdriver.ChromeOptions()
options.binary_location=chrome_location
# driver=webdriver.Chrome(options=options)


# 指定Chromedriver驱动位置，service参数
driver_location=r"D:\py\chromedriver.exe"
service=Service(driver_location)
driver=webdriver.Chrome(options=options,service=service)

# 打开网页
driver.get(url)
sleep(3)

